package com.jt.controller;

import com.jt.pojo.Item;
import com.jt.service.ShopService;

import com.jt.vo.PageResult;
import com.jt.vo.SysResult;
import com.jt.vo.itemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("item")
public class ShopController {
    @Autowired
    private ShopService shopService ;
//    @GetMapping("findAll")
//    public SysResult findall (@PathVariable Integer id ){
//        return  shopService.findAll(id);
//    }
    @GetMapping("getItemList")
    public SysResult shop(PageResult pageResult){
        pageResult= shopService.getItemList(pageResult);
        return SysResult.success(pageResult);
    }
    @PostMapping("/saveItem")
        public SysResult saveItem(@RequestBody itemVO itemVO){
        shopService.saveItem(itemVO);
        return SysResult.success();
    }
    @DeleteMapping("deleteItemById")
    public SysResult deleteItemById(Integer id){
        shopService.deleteItemById(id);
        return SysResult.success();
    }
    @PutMapping("updateItemStatus")
    public SysResult updateItemStatus(@RequestBody  Item item){
        shopService.updateItemStatus(item);
        return SysResult.success();
    }
}
